<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../../files/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000551">===</a>&nbsp;&nbsp;
      <a href="#M000552">days_in_month</a>&nbsp;&nbsp;
      <a href="#M000555">local_time</a>&nbsp;&nbsp;
      <a href="#M000553">time_with_datetime_fallback</a>&nbsp;&nbsp;
      <a href="#M000554">utc_time</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000551" class="method-detail">
        <a name="M000551"></a>

        <div class="method-heading">
          <a href="#M000551" class="method-signature">
          <span class="method-name">===</span><span class="method-args">(other)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Overriding case equality method so that it returns true for <a
href="../../../TimeWithZone.html">ActiveSupport::TimeWithZone</a> instances
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000551-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000551-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 30</span>
30:           <span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">other</span>)
31:             <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-operator">::</span><span class="ruby-constant">Time</span>)
32:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000552" class="method-detail">
        <a name="M000552"></a>

        <div class="method-heading">
          <a href="#M000552" class="method-signature">
          <span class="method-name">days_in_month</span><span class="method-args">(month, year = now.year)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Return the number of days in the given month. If no year is specified, it
will use the current year.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000552-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000552-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 36</span>
36:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">days_in_month</span>(<span class="ruby-identifier">month</span>, <span class="ruby-identifier">year</span> = <span class="ruby-identifier">now</span>.<span class="ruby-identifier">year</span>)
37:             <span class="ruby-keyword kw">return</span> <span class="ruby-value">29</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">gregorian_leap?</span>(<span class="ruby-identifier">year</span>)
38:             <span class="ruby-constant">COMMON_YEAR_DAYS_IN_MONTH</span>[<span class="ruby-identifier">month</span>]
39:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000555" class="method-detail">
        <a name="M000555"></a>

        <div class="method-heading">
          <a href="#M000555" class="method-signature">
          <span class="method-name">local_time</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Wraps class method <tt><a
href="ClassMethods.html#M000553">time_with_datetime_fallback</a></tt> with
<tt>utc_or_local</tt> set to <tt>:local</tt>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000555-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000555-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 57</span>
57:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">local_time</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
58:             <span class="ruby-identifier">time_with_datetime_fallback</span>(<span class="ruby-identifier">:local</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
59:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000553" class="method-detail">
        <a name="M000553"></a>

        <div class="method-heading">
          <a href="#M000553" class="method-signature">
          <span class="method-name">time_with_datetime_fallback</span><span class="method-args">(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time if requested year can be accommodated by Ruby&#8216;s
Time class (i.e., if year is within either 1970..2038 or 1902..2038,
depending on system architecture); otherwise returns a DateTime
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000553-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000553-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 44</span>
44:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time_with_datetime_fallback</span>(<span class="ruby-identifier">utc_or_local</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>=<span class="ruby-value">1</span>, <span class="ruby-identifier">day</span>=<span class="ruby-value">1</span>, <span class="ruby-identifier">hour</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">min</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">usec</span>=<span class="ruby-value">0</span>)
45:             <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">utc_or_local</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">usec</span>)
46:           <span class="ruby-keyword kw">rescue</span>
47:             <span class="ruby-identifier">offset</span> = <span class="ruby-identifier">utc_or_local</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:local</span> <span class="ruby-operator">?</span> <span class="ruby-operator">::</span><span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">local_offset</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
48:             <span class="ruby-operator">::</span><span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">offset</span>)
49:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000554" class="method-detail">
        <a name="M000554"></a>

        <div class="method-heading">
          <a href="#M000554" class="method-signature">
          <span class="method-name">utc_time</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Wraps class method <tt><a
href="ClassMethods.html#M000553">time_with_datetime_fallback</a></tt> with
<tt>utc_or_local</tt> set to <tt>:utc</tt>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000554-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000554-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 52</span>
52:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">utc_time</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
53:             <span class="ruby-identifier">time_with_datetime_fallback</span>(<span class="ruby-identifier">:utc</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
54:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>